﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>ERP仓储管理系统</title>
    <link href="css/style.css" rel="stylesheet" type="text/css"/>
    <script language="JavaScript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/axios.js"></script>
    <script type="text/javascript" src="js/api.js"></script>
    <script src="js/cloud.js" type="text/javascript"></script>

    <script language="javascript">
        $(function () {
            $('.loginbox').css({'position': 'absolute', 'left': ($(window).width() - 692) / 2});
            $(window).resize(function () {
                $('.loginbox').css({'position': 'absolute', 'left': ($(window).width() - 692) / 2});
            })
        });

        function tipOpen(content) {
            $(".tipright p").text(content);
            $("#tip").fadeIn(200);
        }
        function tipClose() {
            $("#tip").fadeOut(200);
        }
    </script>

</head>

<body style="background-color:#df7611; background-image:url(images/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;">

<div id="mainBody">
    <div id="cloud1" class="cloud"></div>
    <div id="cloud2" class="cloud"></div>
</div>


<div class="logintop">
    <span>ERP仓储管理系统</span>
</div>

<div class="loginbody">

    <span class="systemlogo"></span>

    <div class="loginbox loginbox1">

        <ul>
            <li><input name="" type="text" class="loginuser" value="admin" onclick="JavaScript:this.value=''"/></li>
            <li><input name="" type="text" class="loginpwd" value="密码" onclick="JavaScript:this.value=''"/></li>
            <li class="yzm">
                <span><input id="test" name="" type="text" value="验证码"
                             onclick="JavaScript:this.value=''"/></span><cite>X3D5S</cite>
            </li>
            <li><input name="" type="button" class="loginbtn" value="登录"
                       onclick="login()"/><label><input name="" type="checkbox" value=""
                                                                                       checked="checked"/>记住密码</label><label><a
                    href="#">忘记密码？</a></label></li>
        </ul>


    </div>

</div>

<div id="tip" class="tip">
    <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
    <div class="tipinfo"> <span><img src="./images/ticon.png" /></span>
        <div class="tipright">
            <p></p>
            <cite>如果是请点击确定按钮 ，否则请点取消。</cite> </div>
    </div>
    <div class="tipbtn">
        <input name="" type="button"  class="sure" value="确定" onclick="tipClose()" />
        &nbsp;
<!--        <input name="" type="button"  class="cancel" value="取消" onclick="tipClose()" />-->
    </div>
</div>


<div class="loginbm">版权归南昌朝腾科技所有，仅供学习交流，勿用于任何商业用途</div>
<script type="text/javascript">
    function login() {
        axiosJson("post", "/system/permission/login", null, {
            username: $(".loginuser").val(),
            password: $(".loginpwd").val()
        }).then((res) => {
            let resultMsg = res.data;
            if (resultMsg.code === 200) {
                localStorage.setItem("uId", resultMsg.data.user.uId);
                localStorage.setItem("username", resultMsg.data.user.uName);
                localStorage.setItem("token", resultMsg.data.token);
                window.location = "main.html";
            } else if (resultMsg.code === 401) {
                tipOpen(resultMsg.message)
            } else if (resultMsg.code === 402) {
                tipOpen(resultMsg.message)
            } else {
                tipOpen("服务器异常")
            }
        }).catch(() => {
            tipOpen("服务器异常")
        })
    }

    axiosRequest("get", "/system/permission/uIdCheck").then((res)=>{
        let resultMsg = res.data;
        if (resultMsg.code === 200) {
            window.location = 'main.html'
        }
    })
</script>
</body>
</html>
